<?php
$MDAC = 'RD';
$QurAC = '';
$prStr = '';
if (isset($_POST['RID'])) {
	$OBJCTRC = $_POST['RID'];
} elseif (isset($_GET['RID'])) {
	$OBJCTRC = $_GET['RID'];
}
if (!isset($OBJCTRC)) {
	die("Erro ao obter dados de contas.");
}
if (isset($_POST['AID'])) {
	$OBJCTAC = $_POST['AID'];
} elseif (isset($_GET['AID'])) {
	$OBJCTAC = $_GET['AID'];
}
$CheckRows = 'bgcolor="#DADADA" class="Selector"
		onMouseOver="this.className=\'Selector_Over\'"
		onMouseOut="this.className=\'Selector\'"
		onClick="this.className=\'Selector_Click\';';
if (isset($OBJCTAC) && $OBJCTAC > 0) {
	$QurAC = " AND cb_Id = {$OBJCTAC}";
}
	$FloatQur = ' AND cb_Status = 2';
	if (isset($_POST['AccViewMode']) && $_POST['AccViewMode'] == 1) {
		$FloatQur = ' AND cb_Status IN (2,4)';
	}

	$getDadosDaConta = "
    select
    cb_Id
    , cb_Beneficiario
    , cb_Banco
    , bp_Name              as cb_Banco
    , cb_Sucursal
    , cb_CiudadSucursal
    , cb_Cuenta_mod
    , CiuCiudad            as cb_CiudadSucursal
    , hf_actypes.TYPE_NAME as cb_TipoCuenta
    , cb_Cuenta
    , cb_Cuenta_prx
    , cb_Cuenta_sux
    , cb_Usuario
    , cb_Fecha
from officeschema.beneficiarioscuentas
    LEFT OUTER JOIN officeschema.hf_actypes on officeschema.hf_actypes.REF = cb_TipoCuenta
    LEFT OUTER JOIN officeschema.ciudades on CiuNumero = cb_CiudadSucursal
    LEFT OUTER JOIN officeschema.hd_bancos on bp_ID = cb_Banco
where cb_Beneficiario = {$OBJCTRC} {$QurAC} {$FloatQur}
    ";

	$Account = $GLOBALS['MYT']->db_array($getDadosDaConta);


	for ($ac = 1; $ac <= $Account[0]; $ac++) {
		if ($_POST['CST'] == 0) {
			$nvstr = 'onClick="
		document.ReceiverProperties.AID.value=\'' . $Account[$ac]['cb_Id'] . '\';
		document.ReceiverProperties.action=\'_response/call.php?get=cliente/conta\';
		subform(\'ReceiverProperties\',\'inv_MP\');
		document.ReceiverProperties.action=\'_response/call.php?get=Operative/receiveraccount\';
		subform(\'ReceiverProperties\',\'AC_List\');
		document.ReceiverProperties.action=\'_response/call.php?get=Operative/invoice\';
		subform(\'ReceiverProperties\',\'OrderProp\');" NOWRAP';
		} else {
			$nvstr = ' NOWRAP';
		}
		$prStr .= '<tr ' . $CheckRows . '">
          <td onClick="document.ReceiverProperties.AID.value=' . $Account[$ac]['cb_Id'] . ';
		document.ReceiverProperties.action=\'_response/call.php?get=Operative/view/viewreceiveraccount\';
		subform(\'ReceiverProperties\',\'NWAC\');"><img src="_response/bin.php?get=edit.gif"></td>
			<td ' . $nvstr . ' width="10%">';
		$prStr .= rt_field('text', $MDAC, 'cb_Cuenta', $Account[$ac]['cb_Id'], '20', '16', 'False', '');
		$prStr .= '</td>
            <td ' . $nvstr . '>';
		$prStr .= rt_field('text', $MDAC, 'cb_Banco', $Account[$ac]['cb_Banco'], '50', '35', 'False', '');
		$prStr .= '</td>
            <td ' . $nvstr . ' width="10%">';
		$prStr .= rt_field('text', $MDAC, 'cb_Sucursal', $Account[$ac]['cb_Sucursal'], '10', '10', 'False', '');
		$prStr .= '</td>
            <td ' . $nvstr . '>';
		$prStr .= bpcorrconv($Account[$ac]['cb_Banco'], 0, $Account[$ac]['cb_Cuenta'], $Account[$ac]['cb_TipoCuenta'], $Account[$ac]['cb_Cuenta_prx'], $Account[$ac]['cb_Cuenta_sux'], $Account[$ac]['cb_Cuenta_mod']);
		$prStr .= '</td>
		    <td ' . $nvstr . '>';
		$prStr .= rt_field('text', $MDAC, 'cb_TipoCuenta', $Account[$ac]['cb_TipoCuenta'], '10', '10', 'False', '');
		$prStr .= '</td>
            <td ' . $nvstr . ' width="20%">';
		if (is_numeric($Account[$ac]['cb_CiudadSucursal'])) {
			$prStr .= rt_field('text', $MDAC, 'cb_CiudadSucursal', $Account[$ac]['cb_CiudadSucursal'], '20', '16', 'False', '');
		} else {
			$prStr .= $Account[$ac]['cb_CiudadSucursal'];
		}
		$prStr .= '</td>
        </tr>';
	}
	?>

<table width="100%" border="0" cellspacing="1" cellpadding="1">
	<tr bgcolor="#BACCD1">
		<td></td>
		<td width="15%">Número</td>
		<td width="35%">Banco</td>
		<td width="10%">Agência</td>
		<td width="20%">Conta</td>
		<td>Tipo</td>
		<td width="20%">Cidade</td>
	</tr>
	<?php echo $prStr; ?>
</table>
